var nowDate = getDay(0);
var pageType = sessionStorage.getItem('pageType');
if(pageType == '' && sessionStorage.getItem("pageType") != 'null' && sessionStorage.getItem("pageType") != null){
	pageType = sessionStorage.getItem("pageType");
}
var calendar = new lCalendar();
var pandiancalendar = new lCalendar();
var url;
pandiancalendar.init({
	'trigger': '#pandianDate',
	'type': 'date',
	'minDate': '2022-01-01',
	'maxDate': '2099-12-31'
});
function ICalendarClick(){
//	onload()
}
$(document).ready(function(){
	$('#name').text(sessionStorage.getItem("name"));
	$('#pandianDate').val(nowDate);
	$('#searchButton').on('click',function(){
		getPandianJiancha();
	});
	if(sessionStorage.getItem("job") == 'Store'){
		$('#pandianShop').val(sessionStorage.getItem("shopcode"))
		$('#pandianShop').attr('readonly','readonly');
	}
	getPandianJiancha();
});

//查询门店信息
function getPandianJiancha(){
	var sendData = {};
	sendData.shopcode=$('#pandianShop').val();
	sendData.pandianDate=$('#pandianDate').val();
	sendData.flag='8,7';
	if(pageType == 'yingyun'){
		sendData.jobnumber=sessionStorage.getItem("jobnumber");
		sendData.job=sessionStorage.getItem("job");
	}
	if(pageType == 'pandian'){
		sendData.wanchengUser=sessionStorage.getItem("userId");
	}
	$.ajax({
		url: "../pandianevery/getPandianJiancha"
		,type:'post'
//		,async: false
		,data:JSON.stringify(sendData)
		,contentType: "application/json; charset=utf-8"
		,dataType:'json'
		,success: function(res){
			console.log(res)
			
			$('#opeTable').empty();
			if(res.success){
				var resdata = res.data;
				for (var i = 0; i < resdata.length; i++) {
					$('#opeTable').append('<tr class="thin-border-bottom" onclick="startPandian('+resdata[i].id+',\''+resdata[i].shopcode+'\',\''+resdata[i].shopname+'\','+resdata[i].flag+',\''+resdata[i].sEmployeeNO+'\',\''+resdata[i].sEmployeeName+'\')">'
							+'	<td style="padding-left: 0px;padding-right: 0px;display: table-cell; vertical-align: middle;">'+resdata[i].shopcode+'</span></td>'
							+'	<td style="padding-left: 0px;padding-right: 0px;display: table-cell; vertical-align: middle;">'+resdata[i].shopname+'</td>'//id="'+el+obj+i+'"
							+'	<td style="padding-left: 0px;padding-right: 0px;display: table-cell; vertical-align: middle;">'+resdata[i].pandianDate+'</td>'//id="'+el+obj+i+'"
							+'	<td style="padding-left: 0px;padding-right: 0px;display: table-cell; vertical-align: middle;" class="orange">'+resdata[i].flagname+'</td>'
							+'</tr>');
				}
				
			}else{
//				layer.alert(res.message);
			}
		}
		,error:function(XMLHttpRequest, textStatus, errorThrown) {
			 console.log(XMLHttpRequest);
			 console.log(textStatus);
			 console.log(errorThrown);
			 hideloading();
		}
	});
	
}

//开始盘点
function startPandian(id,shopcode,shopname,pandianFlag,dudaoNO,dudaoName){
	
	
	sessionStorage.setItem("shopcode",shopcode);
	sessionStorage.setItem("shopname",shopname);
	sessionStorage.setItem("dudaoNO",dudaoNO);
	sessionStorage.setItem("dudaoName",dudaoName);
	window.location.href='toJiancha_jieguo_detail?pandianid='+id;
}